1. Field of the Invention
The present invention relates generally to shared memory multiprocessor systems, and more particularly to a memory optimization state for requesting data utilized by software locks.
2. Related Art
In many multiprocessor systems, all of the processors access a common memory, referred to as main memory. Typically, main memory is not capable of supplying data and instructions to multiple processors at adequate speeds. To compensate for the speed deficiencies of main memory, caches are usually incorporated. Caches are small high-speed memories, located between main memory and the processor, that are continuously updated to contain recently accessed contents of main memory. A cache copy of the contents of main memory can be accessed at a much higher speed than from main memory.
In multiprocessor systems, caches are usually attached to each processor. Thus, copies of a data unit from main memory can be stored on multiple caches at any given time. The modification of such shared data by any given processor can lead to data inconsistencies. Such inconsistencies result in cache coherence problems. Solutions to cache coherence problems must ensure that only one device has write access to a particular data unit at any given time while multiple devices may have read access to shared data. In other words, coherency requires that a read of a data unit return the value of that data unit most recently written, and a write of a data unit invalidate all copies of that data unit possessed by all other devices having read access.
In multiprocessor systems, data can either be shared among many devices or held exclusively by one device. When data is shared among many devices, each device is given read access to the data. When data is held exclusively by one device, that device is allowed, but not required, to modify the data.
Cache coherence protocols are used to maintain data consistency in multiprocessor systems with private caches. One such cache coherence protocol is the MESI (Modified Exclusive Shared Invalid) protocol. Single bus multiprocessor systems using a MESI protocol allow the devices on the bus the ability to snoop the bus to observe all data requests on the bus. In a MESI protocol a cache will snoop the request bus to ascertain the status of a data unit that it is requesting. If it is determined that no other device, with the exception of main memory, is currently holding a copy of that data unit, then the cache can obtain that data unit in the exclusive state, and thus write to that data unit without having to go back to the bus to acquire ownership or exclusive rights.
In a multiprocessor system comprising a hierarchy of buses, the ability to snoop the bus to determine the status of a data unit on all devices in the system no longer exists. When a processor requests read access to a data unit, the system must now decide whether to give the data to the processor in a shared state or in an exclusive state. In conventional systems, the general technique used is to provide the data in the shared state, and if the processor later desires write access to the data, the processor must go back to the bus and request that the data be given in the exclusive state. The system will then obtain exclusive rights and grant those rights to that processor.
This pattern of fetching the data in the shared state to read it and then later returning to the bus to request the same data in the exclusive state in order to write it, is a typical access pattern for a location of data being used as a software lock. A software lock is a software mechanism used to prevent a unit of data used by a software structure or process from having conflicting operations simultaneously being performed on that same unit of data by some other process in the system. The software structure will first read the data in the shared state or snoop the lock. If the software observes that the data unit is already locked, the software structure will not try to obtain write access to it, and possibly may go off and do other things. On the other hand, if the software snoops at the data and observes that the data unit is not locked, it will obtain exclusive rights and attempt to lock the data for its exclusive use.
This method of having to first observe if a data unit is locked and then attempt to retrieve the data unit in the exclusive state in order to lock the data unit for software operations can prevent efficient performance of software operations. What is needed is a system and method for optimizing data requests for data units being utilized as software locks.